home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / xpcom / nsIInputStream.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  8KB  |  216 lines

  1. /*
  2.  * DO NOT EDIT.  THIS FILE IS GENERATED FROM nsIInputStream.idl
  3.  */
  4.  
  5. #ifndef __gen_nsIInputStream_h__
  6. #define __gen_nsIInputStream_h__
  7.  
  8.  
  9. #ifndef __gen_nsISupports_h__
  10. #include "nsISupports.h"
  11. #endif
  12.  
  13. /* For IDL files that don't want to include root IDL files. */
  14. #ifndef NS_NO_VTABLE
  15. #define NS_NO_VTABLE
  16. #endif
  17. class nsIInputStream; /* forward declaration */
  18.  
  19. /**
  20.  * The signature of the writer function passed to ReadSegments. This
  21.  * is the "consumer" of data that gets read from the stream's buffer.
  22.  *
  23.  * @param aInStream stream being read
  24.  * @param aClosure opaque parameter passed to ReadSegments
  25.  * @param aFromSegment pointer to memory owned by the input stream
  26.  * @param aToOffset amount already read (since ReadSegments was called)
  27.  * @param aCount length of fromSegment
  28.  * @param aWriteCount number of bytes read
  29.  *
  30.  * Implementers should return the following:
  31.  *
  32.  * @return NS_OK and (*aWriteCount > 0) if consumed some data
  33.  * @return <any-error> if not interested in consuming any data
  34.  *
  35.  * Errors are never passed to the caller of ReadSegments.
  36.  *
  37.  * NOTE: returning NS_OK and (*aWriteCount = 0) has undefined behavior.
  38.  *
  39.  * @status FROZEN
  40.  */
  41. typedef NS_CALLBACK(nsWriteSegmentFun)(nsIInputStream *aInStream,
  42.                                        void *aClosure,
  43.                                        const char *aFromSegment,
  44.                                        PRUint32 aToOffset,
  45.                                        PRUint32 aCount,
  46.                                        PRUint32 *aWriteCount);
  47.  
  48. /* starting interface:    nsIInputStream */
  49. #define NS_IINPUTSTREAM_IID_STR "fa9c7f6c-61b3-11d4-9877-00c04fa0cf4a"
  50.  
  51. #define NS_IINPUTSTREAM_IID \
  52.   {0xfa9c7f6c, 0x61b3, 0x11d4, \
  53.     { 0x98, 0x77, 0x00, 0xc0, 0x4f, 0xa0, 0xcf, 0x4a }}
  54.  
  55. class NS_NO_VTABLE nsIInputStream : public nsISupports {
  56.  public: 
  57.  
  58.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IINPUTSTREAM_IID)
  59.  
  60.   /**
  61.  * nsIInputStream
  62.  *
  63.  * @status FROZEN
  64.  */
  65. /** 
  66.      * Close the stream.
  67.      */
  68.   /* void close (); */
  69.   NS_IMETHOD Close(void) = 0;
  70.  
  71.   /**
  72.      * @return number of bytes currently available in the stream
  73.      */
  74.   /* unsigned long available (); */
  75.   NS_IMETHOD Available(PRUint32 *_retval) = 0;
  76.  
  77.   /** 
  78.      * Read data from the stream.
  79.      *
  80.      * @param aBuf the buffer into which the data is to be read
  81.      * @param aCount the maximum number of bytes to be read
  82.      *
  83.      * @return number of bytes read (may be less than aCount).
  84.      * @return 0 if reached end of file
  85.      *
  86.      * @throws NS_BASE_STREAM_WOULD_BLOCK if reading from the input stream would
  87.      *   block the calling thread (non-blocking mode only)
  88.      * @throws <other-error> on failure
  89.      */
  90.   /* [noscript] unsigned long read (in charPtr aBuf, in unsigned long aCount); */
  91.   NS_IMETHOD Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval) = 0;
  92.  
  93.   /**
  94.      * Low-level read method that has access to the stream's underlying buffer.
  95.      * The writer function may be called multiple times for segmented buffers.
  96.      * ReadSegments is expected to keep calling the writer until either there is
  97.      * nothing left to read or the writer returns an error.  ReadSegments should
  98.      * not call the writer with zero bytes to consume.
  99.      *
  100.      * @param aWriter the "consumer" of the data to be read
  101.      * @param aClosure opaque parameter passed to writer 
  102.      * @param aCount the maximum number of bytes to be read
  103.      *
  104.      * @return number of bytes read (may be less than aCount)
  105.      * @return 0 if reached end of file (or if aWriter refused to consume data)
  106.      *
  107.      * @throws NS_BASE_STREAM_WOULD_BLOCK if reading from the input stream would
  108.      *   block the calling thread (non-blocking mode only)
  109.      * @throws <other-error> on failure
  110.      *
  111.      * NOTE: this function may be unimplemented if a stream has no underlying
  112.      * buffer (e.g., socket input stream).
  113.      */
  114.   /* [noscript] unsigned long readSegments (in nsWriteSegmentFun aWriter, in voidPtr aClosure, in unsigned long aCount); */
  115.   NS_IMETHOD ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval) = 0;
  116.  
  117.   /**
  118.      * @return true if stream is non-blocking
  119.      */
  120.   /* boolean isNonBlocking (); */
  121.   NS_IMETHOD IsNonBlocking(PRBool *_retval) = 0;
  122.  
  123. };
  124.  
  125. /* Use this macro when declaring classes that implement this interface. */
  126. #define NS_DECL_NSIINPUTSTREAM \
  127.   NS_IMETHOD Close(void); \
  128.   NS_IMETHOD Available(PRUint32 *_retval); \
  129.   NS_IMETHOD Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval); \
  130.   NS_IMETHOD ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval); \
  131.   NS_IMETHOD IsNonBlocking(PRBool *_retval); 
  132.  
  133. /* Use this macro to declare functions that forward the behavior of this interface to another object. */
  134. #define NS_FORWARD_NSIINPUTSTREAM(_to) \
  135.   NS_IMETHOD Close(void) { return _to Close(); } \
  136.   NS_IMETHOD Available(PRUint32 *_retval) { return _to Available(_retval); } \
  137.   NS_IMETHOD Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval) { return _to Read(aBuf, aCount, _retval); } \
  138.   NS_IMETHOD ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval) { return _to ReadSegments(aWriter, aClosure, aCount, _retval); } \
  139.   NS_IMETHOD IsNonBlocking(PRBool *_retval) { return _to IsNonBlocking(_retval); } 
  140.  
  141. /* Use this macro to declare functions that forward the behavior of this interface to another object in a safe way. */
  142. #define NS_FORWARD_SAFE_NSIINPUTSTREAM(_to) \
  143.   NS_IMETHOD Close(void) { return !_to ? NS_ERROR_NULL_POINTER : _to->Close(); } \
  144.   NS_IMETHOD Available(PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Available(_retval); } \
  145.   NS_IMETHOD Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->Read(aBuf, aCount, _retval); } \
  146.   NS_IMETHOD ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->ReadSegments(aWriter, aClosure, aCount, _retval); } \
  147.   NS_IMETHOD IsNonBlocking(PRBool *_retval) { return !_to ? NS_ERROR_NULL_POINTER : _to->IsNonBlocking(_retval); } 
  148.  
  149. #if 0
  150. /* Use the code below as a template for the implementation class for this interface. */
  151.  
  152. /* Header file */
  153. class nsInputStream : public nsIInputStream
  154. {
  155. public:
  156.   NS_DECL_ISUPPORTS
  157.   NS_DECL_NSIINPUTSTREAM
  158.  
  159.   nsInputStream();
  160.  
  161. private:
  162.   ~nsInputStream();
  163.  
  164. protected:
  165.   /* additional members */
  166. };
  167.  
  168. /* Implementation file */
  169. NS_IMPL_ISUPPORTS1(nsInputStream, nsIInputStream)
  170.  
  171. nsInputStream::nsInputStream()
  172. {
  173.   /* member initializers and constructor code */
  174. }
  175.  
  176. nsInputStream::~nsInputStream()
  177. {
  178.   /* destructor code */
  179. }
  180.  
  181. /* void close (); */
  182. NS_IMETHODIMP nsInputStream::Close()
  183. {
  184.     return NS_ERROR_NOT_IMPLEMENTED;
  185. }
  186.  
  187. /* unsigned long available (); */
  188. NS_IMETHODIMP nsInputStream::Available(PRUint32 *_retval)
  189. {
  190.     return NS_ERROR_NOT_IMPLEMENTED;
  191. }
  192.  
  193. /* [noscript] unsigned long read (in charPtr aBuf, in unsigned long aCount); */
  194. NS_IMETHODIMP nsInputStream::Read(char * aBuf, PRUint32 aCount, PRUint32 *_retval)
  195. {
  196.     return NS_ERROR_NOT_IMPLEMENTED;
  197. }
  198.  
  199. /* [noscript] unsigned long readSegments (in nsWriteSegmentFun aWriter, in voidPtr aClosure, in unsigned long aCount); */
  200. NS_IMETHODIMP nsInputStream::ReadSegments(nsWriteSegmentFun aWriter, void * aClosure, PRUint32 aCount, PRUint32 *_retval)
  201. {
  202.     return NS_ERROR_NOT_IMPLEMENTED;
  203. }
  204.  
  205. /* boolean isNonBlocking (); */
  206. NS_IMETHODIMP nsInputStream::IsNonBlocking(PRBool *_retval)
  207. {
  208.     return NS_ERROR_NOT_IMPLEMENTED;
  209. }
  210.  
  211. /* End of implementation class template. */
  212. #endif
  213.  
  214.  
  215. #endif /* __gen_nsIInputStream_h__ */
  216.